package com.sn.pw.controller;


import com.sn.pw.page.PageResp;
import com.sn.pw.result.Result;
import com.sn.pw.service.OrderService;
import com.sn.pw.vo.req.PickingOrderPageQueryReq;
import com.sn.pw.vo.req.ShippingOrderPageReq;
import com.sn.pw.vo.req.ShippingOrderReq;
import com.sn.pw.vo.resp.ShippingOrderResp;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Api(tags = "出货订单-Api")
@RestController
@RequestMapping("/shipping")
public class ShippingOrderController {

    @Resource
    private OrderService orderService;

    @PostMapping("/publishOrder")
    @ApiOperation(value = "发布订单")
    public Result publishOrder(@Valid @RequestBody ShippingOrderReq param) {
        return Result.success(orderService.publicOrder(param));
    }

    @ApiOperation(value = "分页获取出货订单")
    @PostMapping(value = "/pageRetrieveOrders")
    public Result<PageResp<ShippingOrderResp>> pageRetrieveOrders(@Valid @RequestBody ShippingOrderPageReq pageReq) {
        return Result.success(orderService.pageRetrieveOrder(pageReq));
    }

    @PostMapping("/findPage")
    @ApiOperation(value = "分页查询")
    public Result<PageResp<ShippingOrderResp>>findPage(@Valid @RequestBody PickingOrderPageQueryReq pageReq){
        return Result.success(orderService.findPage(pageReq));
    }


}
